﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Globalization;
using System.Threading;

namespace System
{
    public static class Utils
    {
        public static string GetVirtualPath(this string physicalPath)
        {
            string rootpath = HttpContext.Current.Server.MapPath("~/");
            physicalPath = physicalPath.Replace(rootpath, "");
            physicalPath = physicalPath.Replace("\\", "/");
            return "~/" + physicalPath;
        }

        public static string GetClientPath(this string physicalPath)
        {
           return VirtualPathUtility.ToAbsolute(GetVirtualPath(physicalPath));
        }

        public static CultureInfo Culture
        {
            get
            {
                var lang = HttpContext.Current.Session["Lang"] as string;
                if (lang != null)
                    return new CultureInfo(lang);
                else
                    return Thread.CurrentThread.CurrentCulture;
            }
            set
            {
                HttpContext.Current.Session["Lang"] = value.Name;
            }
        }
    }

    public enum EditorMode
    {
        View,
        Edit
    }
}